<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <title>显示公告</title>
    <script src="js/sockjs.js"></script>
    <script src="js/stomp.js"></script>
    <script src="js/jquery-3.2.1.js"></script>
</head>
<body>
<p id="showNotice"></p>

<script type="text/javascript">

    $(document).ready(function () {
        var s = new SockJS('/webSocket');
        var stompClient = Stomp.over(s);
        stompClient.connect({}, function () {
            console.log('notice socket connected!');
            stompClient.subscribe('/client/showNotice', function (data) {
                $('#showNotice').html(data.body);
            });
        });
    })


</script>
</body>
</html>